package org.rapan;

import org.rapan.jpa.Consultant;

import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Button.ClickEvent;

@SuppressWarnings("serial")
public abstract class ProfileLayout extends VerticalLayout {

	public ProfileLayout(final Consultant c, boolean editable) {
		super();

		setSpacing(true);
		setMargin(true);

		if (editable) {
			Button editButton = new Button("Edit");
			editButton.addListener(new ClickListener() {

				public void buttonClick(ClickEvent event) {
					editButtonSelected(c);
				}
			});
			addComponent(editButton);
		}

		addComponent(new Label("Name : " + c.getFullName()));
		addComponent(new Label("Email : " + c.getEmail()));
		addComponent(new Label("Position : " + c.getPosition()));
		addComponent(new Label("Started Working for us at : "
				+ c.getStartDate()));
		if (c.getEndDate() != null)
			addComponent(new Label("Quit at : " + c.getEndDate()));
		Button reportButton = new Button("Show Completeled Reports");
		reportButton.addListener(new ClickListener() {

			public void buttonClick(ClickEvent event) {
				getWindow().addWindow(new ReportsWindow(c));
			}
		});
		addComponent(reportButton);
	}

	public abstract void editButtonSelected(Consultant c);

}
